package com.balance.controller.sys;

import com.balance.pojo.common.CommonPojo;
import com.balance.pojo.common.CommonResult;
import com.balance.pojo.sys.SysRole;
import com.balance.pojo.sys.SysRoleMenuDTO;
import com.balance.pojo.sys.SysUser;
import com.balance.service.sys.ISysRoleService;
import jakarta.servlet.http.HttpServletRequest;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.net.http.HttpRequest;
import java.util.List;

/**
 * @Title: SysRoleController
 * @Author 小东
 * @Package com.balance.controller.sys
 * @Date 2025/3/28 13:50
 * @description: 权限接口
 */
@RestController
@RequestMapping("sys/role")
public class SysRoleController {
    @Autowired
    private ISysRoleService iSysRoleService;

    // 查询角色列表（带菜单权限）
    @GetMapping("/list")
    public CommonResult<List<SysRole>> selectRoleListWithMenus(){
        return CommonResult.success(iSysRoleService.selectRoleListWithMenus()) ;
    }


    // 分配角色菜单权限()
    @PostMapping
    CommonResult<Integer> assignRoleMenus(@RequestBody SysRoleMenuDTO sysRoleMenuDTO){
        return CommonResult.success(iSysRoleService.assignRoleMenus(sysRoleMenuDTO.getRoleId(),sysRoleMenuDTO.getMenuIds()));
    }


}
